#!/usr/bin/perl

use Net::SMS::2Way;

my $bulksms_config_file = '/etc/sms.cfg';

my $sms = Net::SMS::2Way->new({config => $bulksms_config_file}) || die "FATAL: Could not create Net::SMS::2Way object!\n";

my $recipient = shift @ARGV;
my $message = shift @ARGV;
my @recipients;
my $usage = "Usage: $0 [recipient[,recipient]] [message]\n";

die $usage unless $recipient;

if ($recipient =~/\d+,\d+/) {
	@recipients = split /,/, $recipient;
} else {
	$recipients[0] = $recipient;
}

my ($status, $status_desc, $quotation) = split( /\|/, $sms->quote_sms($message, @recipients) );

print "Quotation: $quotation ($status_desc)\n";

print 'Error Message: ' . $sms->{error} . "\n" if $sms->{error};
